#!/usr/bin/env bash
get_header () {
for i in $(seq $NUMROWS); do
IFS= read -r LINE
OLDHEADER="${OLDHEADER}${LINE}\n"
done
}
print_header () {
echo -ne "$1"
}
print_body () {
cat
}
OLDHEADER=
NUMROWS=1
while getopts "dn:ha:r:e:" OPTION
do
case $OPTION in
n)
NUMROWS=$OPTARG
;;
a)
print_header "$OPTARG\n"
print_body
exit 1
;;
d)
get_header
print_body
exit 1
;;
r)
get_header
print_header "$OPTARG\n"
print_body
exit 1
;;
e)
get_header
print_header "$(echo -ne $OLDHEADER | eval $OPTARG)\n"
64 | Chapter 5: Scrubbing Data
print_body
exit 1
;;
h)
usage
exit 1
;;
esac
done
get_header
print_header $OLDHEADER
